<template>
  <div class="g2-accout-setting">
    <header class="accout-setting-header">
      <span>基本设置</span>
    </header>
    <main>
      <el-form
        :model="ruleForm"
        :rules="rules"
        label-position="top"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
        size="small"
      >
        <el-row :gutter="60">
          <el-col :span="8">
            <el-form-item label="邮箱" prop="name">
              <el-input v-model="ruleForm.name" style="width:310px;"></el-input>
            </el-form-item>
            <el-form-item label="昵称" prop="name">
              <el-input v-model="ruleForm.name" style="width:310px;"></el-input>
            </el-form-item>
            <el-form-item label="个人简介" prop="name">
              <el-input v-model="ruleForm.name" style="width:310px;"></el-input>
            </el-form-item>
            <el-form-item label="国家/地区" prop="region">
              <el-select v-model="ruleForm.region" placeholder="请选择活动区域">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="submitForm('ruleForm')">更新基本信息</el-button>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="头像" prop="region">
              <div class="account-setting-avator">
                <img
                  src="https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"
                  alt="avatar"
                >
              </div>
              <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/">
                <el-button type="default" size="mini" class="g2-m-l-md" style="margin-left:16px;">
                  <i class="iconfont g2-icon-upload"></i>
                  更换头像
                </el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </main>
  </div>
</template>

<script>
export default {
  name: "PersonSettingBasic",
  props: {},
  components: {},
  data() {
    return {
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: ""
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" }
        ],
        date1: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change"
          }
        ],
        date2: [
          {
            type: "date",
            required: true,
            message: "请选择时间",
            trigger: "change"
          }
        ],
        type: [
          {
            type: "array",
            required: true,
            message: "请至少选择一个活动性质",
            trigger: "change"
          }
        ],
        resource: [
          { required: true, message: "请选择活动资源", trigger: "change" }
        ],
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }]
      }
    };
  },
  computed: {},
  created() {},
  mounted() {},
  watch: {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

<style lang="scss">
.account-setting-avator {
  width: 144px;
  height: 144px;
  margin-bottom: 12px;
  overflow: hidden;
  img {
    width: 100%;
  }
}
.el-upload__input {
  display: none !important;
}
</style>
